<div class="aui-page-panel">
    <div class="login-form">
        <form action="#" method="post" class="aui">
                       <div id="context"></div>
                       <fieldset class="form-fields">
                         <div class="field-group">
                            <label for="username">User Name</label>
                            <input class="text medium-field" type="text" id="username" name="username">
                         </div>
                         <div class="field-group">
                            <label for="password">Password</label>
                            <input class="text medium-field" type="password" id="password" name="password">
                         </div>
                         <fieldset class="group">
                             <div class="checkbox" id="rememberme">
                             <input class="checkbox" id="login-form-remember-me" name="os_cookie" type="checkbox" value="true">
                             <label accesskey="r" for="login-form-remember-me" id="remembermelabel"><u>R</u>emember my login on this computer</label>
                             </div>
                         </fieldset>

                         <div class="field-group">
                                   <input id="btnlogin" type="submit" value="Login" class="aui-button aui-button-primary" />
                                   <a id="btnregister" onclick="alert('NOT AVAILABLE'); return false" href="./register" class="aui-button aui-link-button">Register</a>
                                   <a id="btnforgot" onclick="alert('NOT AVAILABLE'); return false" href="./forgot" class="aui-button aui-link-button">Forgot Password</a>
                         </div>
                         <div class="field-group">
                                    <a onclick="alert('NOT AVAILABLE'); return false" href="./activation/resend" class="link">Resend Activation Email</a>
                         </div>
                       </fieldset>

        </form>
    </div>
</div>

<script>
  AJS.$(function(){
	  AJS.$('#btnlogin').click(function(){
		  var payload = {
				username: AJS.$('#username').val(),
				password: AJS.$('#password').val(),
				remember: (AJS.$('#login-form-remember-me').attr('checked')=='checked') ? true : false
		  };
		  AJS.$('#context').html('');
		  AJS.messages.info("#context", { body: "<p>Authenticating...</p>" });
		  
		  OREG.authenticate(payload,function(response){
		      AJS.log(response);
			  if(response.status=='OK'){
				  // Login success
				  document.location = './home';
			  }else{
				  AJS.$('#context').html('');
				  // Login fail
				  AJS.messages.error("#context", { title:'Login failed',  body: "<p>"+response.result.message+"</p>"} );
			  }
		  }, function(e){
			  AJS.$('#context').html('');
			  // Login fail
			  AJS.messages.error("#context", { title:'Error Occurred',  body: "<p>"+e.message+"</p>"} );
		  });
		  return false;
	  });
	  AJS.$('btnregister').click(function(){
		  
		  
	  });
	  AJS.$('btnforgot').click(function(){
		  
		  
	  });
	  document.getElementById('username').focus();
  });
</script>